<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="app">
        <input type="text">
    </div>
    <script>
        var app = document.getElementById("app")
        var input = document.querySelector("input");
        var arr = [];
        input.onkeyup = function(e){
            if(e.keyCode==13){
                if(input.value!=''){
                    var p = document.createElement("p")
                    p.innerHTML = input.value;
                    if(arr.includes(input.value)) return ;
                    arr.push(input.value)
                    input.value = ""
                    app.appendChild(p)
                    var todos = document.querySelectorAll("#app>p");
                    for(let i=0;i<todos.length;i++){
                        todos[i].onclick = function(){
                            app.removeChild(todos[i])
                        }
                    }
                }
            }
        }
    </script>
</body>
</html>